package leecode.stringAndArray.doublepoint;

public class RemoveElement {
    public static void main(String[] args) {
        int res = removeElement(new int[]{3,2,2,3},3);
        System.out.println(res);
    }

    /*双指针实现元素移除*/
    public static int removeElement(int[] nums, int val) {
        int j=0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i]!=val){
                nums[j]=nums[i];
                j++;
            }
        }
        return j;
    }
}
